package com.javacoo.xservice.base.support.log.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * 应用日志记录相关配置
 * <p>
 * 说明:
 * </p>
 * <li>对应application-*.properties中app.config.log</li>
 * 
 * @author DuanYong
 * @since 2017年7月28日上午9:23:26
 */
@Configuration
@ConfigurationProperties(prefix = LogConfig.PREFIX)
@ConditionalOnProperty(prefix = LogConfig.PREFIX, value = LogConfig.ENABLED, matchIfMissing = true)
public class LogConfig {
    public static final String PREFIX = "app.config.log";
	/** 是否记录日志,默认值*/
	public static final Boolean DEFAULT_RECORD = false;
	/** 日志记录类型:,默认值*/
	public static final String DEFAULT_TYPE= LogTypeEnum.FILE.getValue();
	/** 数据库表空间:,默认值*/
	public static final String DEFAULT_SCHEMA= "test";
	/** 日志保留天数:,默认值*/
	public static final Integer DEFAULT_DAY= 2;
    /** 默认实现:,默认值*/
    public static final String DEFAULT_IMPL= "default";
    public static final String ENABLED = "enabled";
	
	
	/** 是否记录日志：true->开启,false->关闭 */
	private Boolean record = DEFAULT_RECORD;
	/** 日志记录类型:db->记录到数据库,file->以error级别记录到日志文件 */
	private String type = DEFAULT_TYPE;
	/** 数据库表空间 */
	private String schema = DEFAULT_SCHEMA;
	/**日志保留天数*/
	private Integer reserveDay = DEFAULT_DAY;
    /**实现*/
    private String impl = DEFAULT_IMPL;
    /**是否可用*/
    private String enabled = ENABLED;


	/**
	 * 日志类型枚举
	 * <p>
	 * 说明:
	 * </p>
	 * <li></li>
	 * 
	 * @author DuanYong
	 * @since 2017年7月28日上午9:51:48
	 */
	public enum LogTypeEnum {
		/**
		 * 数据库
		 */
		DB("db", "数据库"), 
		/**
		 * 文件
		 */
		FILE("file", "文件");
		private String value;
		private String label;

		private LogTypeEnum(String value, String label) {
			this.value = value;
			this.label = label;
		}

		public String getValue() {
			return value;
		}

		public String getLabel() {
			return label;
		}
	}

    public Boolean getRecord() {
        return record;
    }

    public void setRecord(Boolean record) {
        this.record = record;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getSchema() {
        return schema;
    }

    public void setSchema(String schema) {
        this.schema = schema;
    }

    public Integer getReserveDay() {
        return reserveDay;
    }

    public void setReserveDay(Integer reserveDay) {
        this.reserveDay = reserveDay;
    }

    public String getImpl() {
        return impl;
    }

    public void setImpl(String impl) {
        this.impl = impl;
    }

    public String getEnabled() {
        return enabled;
    }

    public void setEnabled(String enabled) {
        this.enabled = enabled;
    }
}
